home *** CD-ROM | disk | FTP | other *** search
/ Light ROM 1 / LIGHT-ROM 1 (Amiga Library Services)(1994).iso / ffdisks / d939.lha / ExtraCmds / source_etc.lha / src / BumpRev.rexx < prev    next >
OS/2 REXX Batch file  |  1993-10-17  |  3KB  |  97 lines

  1. /*rx
  2.  * BumpRev.rexx - a subset of the BumpRev developer command
  3.  * Copyright (C) 1993 Torsten Poulin
  4.  *
  5.  * This program is free software; you can redistribute it and/or modify
  6.  * it under the terms of the GNU General Public License as published by
  7.  * the Free Software Foundation; either version 2 of the License, or
  8.  * (at your option) any later version.
  9.  *
  10.  * This program is distributed in the hope that it will be useful,
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.  * GNU General Public License for more details.
  14.  *
  15.  * You should have received a copy of the GNU General Public License
  16.  * along with this program; if not, write to the Free Software
  17.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  *
  19.  * The author can be contacted by s-mail at
  20.  *   Torsten Poulin
  21.  *   Banebrinken 99, 2, 77
  22.  *   DK-2400 Copenhagen NV
  23.  *   DENMARK
  24.  *
  25.  */
  26.  
  27. if left(address(), 4) ~== 'WSH_' then address command
  28.  
  29. parse arg version name
  30.  
  31. if ~(datatype(version, 'Whole') & name ~= "") then do
  32.   say 'Usage: BumpRev.rexx <version> <file>'
  33.   say 'Output: <file>_rev.rev and <file>_rev.h'
  34.   exit 20
  35.   end
  36.  
  37. revnumfile=strip(name'_rev.rev')
  38. revfile=strip(name'_rev.h')
  39.  
  40. if ~exists(revnumfile) then
  41.   revnum = 0
  42. else do
  43.   if open(nfile, revnumfile, 'Read') then do
  44.     revnum = readln(nfile)
  45.     call close(nfile)
  46.     end
  47.   else do
  48.     say 'error reading' revnumfile
  49.     exit 10
  50.     end
  51.   end
  52.  
  53. revnum = revnum + 1
  54.  
  55. if open(nfile, revnumfile, 'Write') then do
  56.   call writeln(nfile, revnum)
  57.   call close(nfile)
  58.   end
  59. else do
  60.   say 'error writing' revnumfile
  61.   exit 10
  62.   end
  63.  
  64. if open(hfile, revfile, 'Write') then do
  65.   call outputheaderfile
  66.   call close(nfile)
  67.   end
  68. else do
  69.   say 'error writing' revfile
  70.   exit 10
  71.   end
  72.  
  73. say name 'bumped to' version'.'revnum
  74. exit 0
  75.  
  76.  
  77. outputheaderfile:
  78.   name = reverse(name)
  79.   parse var name name ':' .
  80.   parse var name name '/' .
  81.   name = reverse(name)
  82.  
  83.   parse value date('European') with day '/' month '/' year
  84.   day=strip(day, 'L', '0')
  85.   month=strip(month, 'L', '0')
  86.   year=strip(year, 'L', '0')
  87.   today=day'.'month'.'year
  88.   namever=name version'.'revnum
  89.  
  90.   call writeln(hfile, '#define VERSION' version)
  91.   call writeln(hfile, '#define REVISION' revnum)
  92.   call writeln(hfile, '#define DATE' '"'today'"')
  93.   call writeln(hfile, '#define VERS' '"'namever'"')
  94.   call writeln(hfile, '#define VSTRING' '"'namever '('today')\n\r"')
  95.   call writeln(hfile, '#define VERSTAG "\0$VER:' namever '('today')"')
  96.   return
  97.